import {defHttp} from "/@/utils/http/axios";
import {OrderPageParams} from "/@/api/citic/model/pageModel";
import {OrderTaskParams} from "/@/api/citic/model/taskModel";
import {UploadFileParams} from "/@/api/citic/model/uploadModel";

enum Api {
  upload = "/citic/order/upload",
  retry = "/citic/order/retry/",
  page = "/citic/order/page",
  export = "/citic/order/export/",
  delete = "/citic/order/",
}

export const orderUpload = (params: UploadFileParams,
                            onUploadProgress: (progressEvent: ProgressEvent) => void) => {
  return defHttp.customUploadFile(
    {
      url: Api.upload,
      params
    },
    params
  );
}

export const orderRetry = (params: OrderTaskParams) => {
  return defHttp.put({ url: Api.retry + params.taskId, params });
};

export const orderPage = (params: OrderPageParams) => {
  return defHttp.get({url: Api.page, params: {
      pageNum: params.pageNum,
      pageSize: params.pageSize
    }})
}

export const orderExport = (params: OrderTaskParams) => {
  return defHttp.post({
    url: Api.export + params.taskId, params
  })
}

export const orderDelete = (params: OrderTaskParams) => {
  return defHttp.delete({
    url: Api.delete + params.taskId, params
  })
}

